<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Chatbox extends CI_Controller {
    function  __construct(){
        parent::__construct();
        $this->load->helper('thoigian'); 
    }
    function index(){
        $chat= '';
        $this->load->view('chatbox/chatbox',
            array(                
                'chatc'=>$chat
            )
            );
    }
    function ndchatbox(){
        $data = $this->Home_model->get_data('chatbox','',array(100),array('id','DESC'));        
        if(!empty($data)){
            $this->load->view('chatbox/noidung',array('data'=>$data));
        }
        
    }
    function adddata(){
        if($_POST){
            $this->db->insert(
                'chatbox',
                array(
                    'username'=>$this->session->userdata('user')->username,
                    'time'=>time(),
                    'content'=>$this->input->post('data',true)
                )            
            );
        }
    }
    function resetcb(){
        $this->db->delete('chatbox');
    }
    
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */